/*--------------------------------------------------------------------------------------------------
//Function :
//Revision :
//Modified : vcc gnd led key cmos fa fb
--------------------------------------------------------------------------------------------------*/
#include "PLT_DATA.H"

//==================================================================================================
// 设置温度对应的补偿温度 
//==================================================================================================
DCODE U16 wtTempSet0[6]  = { 50, 100, 150, 200, 250, 280}; //0.空闲
DCODE U16 wtTempSbc0[6]  = {100, 100, 100, 100, 100, 100}; //无补偿为100,大于100位正补偿,小于100为负补偿 

DCODE U16 wtTempSet1[6]  = { 50, 100, 150, 200, 250, 280}; //1.上下管
DCODE U16 wtTempSbc1[6]  = {101, 103, 102,  97,  91,  91};

DCODE U16 wtTempSet2[6]  = { 50, 100, 150, 200, 250, 260}; //2.热风
DCODE U16 wtTempSbc2[6]  = { 94,  95,  95,  93,  93,  93};

DCODE U16 wtTempSet3[6]  = { 50, 100, 150, 200, 250, 260}; //3.上下+风
DCODE U16 wtTempSbc3[6]  = { 94,  94,  94,  93,  90,  90};

DCODE U16 wtTempSet4[6]  = { 50, 100, 150, 200, 225, 250}; //4.上内
DCODE U16 wtTempSbc4[6]  = {110, 127, 138, 140, 144, 148};

DCODE U16 wtTempSet5[6]  = { 50, 100, 150, 200, 250, 260}; //5.双上+风
DCODE U16 wtTempSbc5[6]  = { 94,  94,  95,  97,  93,  93};

DCODE U16 wtTempSet6[6]  = { 50, 100, 150, 200, 250, 260}; //6.双上
DCODE U16 wtTempSbc6[6]  = {105, 124, 133, 132, 131, 130}; //

DCODE U16 wtTempSet7[6]  = { 50, 100, 150, 200, 225, 250}; //7.下+风
DCODE U16 wtTempSbc7[6]  = { 95,  95,  95,  91,  91,  91};

DCODE U16 wtTempSet8[6]  = { 50, 100, 150, 200, 210, 220}; //8.下管
DCODE U16 wtTempSbc8[6]  = { 93,  90,  88,  88,  88,  84};

DCODE U16 wtTempSet9[6]  = { 50, 100, 150, 200, 225, 250}; //9.上管
DCODE U16 wtTempSbc9[6]  = {110, 120, 125, 125, 125, 125};

DCODE U16 wtTempSet10[6] = { 50, 100, 150, 200, 250, 260}; //10.热风eco
DCODE U16 wtTempSbc10[6] = { 94,  95,  97,  97,  96,  96};

DCODE U16 wtTempSet11[6] = { 25,  27,  29,  31,  33,  35}; //11.解冻
DCODE U16 wtTempSbc11[6] = { 95,  95,  95,  95,  95,  95};

DCODE U16 wtTempSet12[6] = { 30,  35,  40,  45,  50,  55}; //12.发酵
DCODE U16 wtTempSbc12[6] = { 93,  93,  93,  93,  93,  93};

DCODE U16 wtTempSet13[6] = { 30,  40,  50,  60,  70,  80}; //13.保温
DCODE U16 wtTempSbc13[6] = { 94,  94,  94,  94,  94,  94};

DCODE U16 wtTempSet14[6] = { 50, 100, 150, 200, 250, 260}; //14.自清洁
DCODE U16 wtTempSbc14[6] = { 93,  93,  93,  93,  93,  93}; //无补偿为100,大于100位正补偿,小于100为负补偿 

//DCODE U16 wtTempSet15[6] = { 50, 100, 150, 200, 250, 260}; //15.空气炸
//DCODE U16 wtTempSbc15[6] = { 94,  95,  97,  98,  97,  97};
DCODE U16 wtTempSet15[6] = { 50, 100, 150, 200, 250, 260}; //15.空气炸
DCODE U16 wtTempSbc15[6] = { 93,  92,  92,  89,  89,  89};

DCODE U16 wtTempSet16[6]  = { 70, 80, 100, 120, 140, 150}; //16 水解功能
DCODE U16 wtTempSbc16[6]  = { 95,  95,  95,  95,  95,  95};

DCODE U16 wtTempSet17[6] = { 50,  60,  70,  80,  85,  90}; //17.干果
DCODE U16 wtTempSbc17[6] = { 94,  94,  94,  110,  110,  115};

DCODE U16 wtFastSet[6] = {100, 125, 150, 175, 200, 250}; //fast 快热 
DCODE U16 wtFastSbc[6] = { 95,  95,  95,  97,  95,  95};

//==================================================================================================
// 变量声明 
//==================================================================================================
BK0 BT  bJdq_F = 0; //继电器电源开关标志 

BK0 BT  bKeepTempDriver_F = 0;
BK3 U8  uKeepTempDriver1Cnt = 0;
BK3 U16 wKeepTempDriver2Cnt = 0;

BK3 U16 wTempSetBc = 0;
BK3 U16 wTempSetBcFrom = 100;
BK3 U16 wFastTempSetBcFrom = 100;
BK3 U16 wTempSetBcAdj = 100;
BK3 U8  uTempSetBcAdj_F = 0;
BK3 U16 wFastHeatBc = 0;
BK3 U8  uFastHeatFirst_F = 0;
BK3 U16 wTempOutHeart = 0;
BK2 U8  uPowerUpCnt = 0;
BK2 U16 wDebugCnt = 0;

BK3 U8  uHwStart1Cnt = 0;
BK3 U16 wHwStart2Cnt = 0;

BK3 U16 wHwStopCnt = 0;
BK3 U16 wHwStopSet = n_20ms_5min;

BK2 U8  uHw_F = 0;
BK3 U8  uHwCnt = 0;
BK3 U16 wHwCnt = 0;

BK3 U8  uFunc10_F = 0;
BK3 U16 wFunc10HeatTime = 0;
BK3 U16 wFunc10KeepTime = 0;
BK3 U8  uFunc10HeatNum = 5;
BK3 U8  uFunc10HeatCnt = 0;

BK3 U8  uFunc14Heat_F = 0;
BK3 U16 wFunc14HeatCnt = 0;

BK3 U8  uFunc15Heat_F = 0;
BK3 U16 wFunc15HeatCnt = 0;

BK3 U16 wSetDec = 0;
BK3 U16 wSetDecBuf = 0;

//==================================================================================================
// 函数声明
//==================================================================================================
void TaskDriver(void); //20ms
U16  YyXx(U16 wYmax,U16 wYmin,U16 wXmax,U16 wXmin,U16 wX);
U16  TempSbc(const U16 *wtSet, const U16 *wtSbc, U16 wSet);
U16  Tempbc(void);
U8   Hw(void); 

//==================================================================================================
// Function    : 过程控制处理
// Input       :
// Output      :
// Description : 20ms 
//==================================================================================================
void TaskDriver(void) //20ms
{
    if((uError_F > 0)&&(uError_F != n_ErrorTime)) //定时到除外 
    {
        bJdq_F = 0;
        uDspLed_F = 0;
    }
    else
    {
        bJdq_F = 1;
    }
    //----------------------------------------------------------------------------------------------
    if(uNewVerison)
    {
        wTempSet = ((U16)wTempSetbf); //显示设置温度 + 25 
    }
    else
    {
        wTempSet = ((U16)uTempSet) + 25; //显示设置温度 + 25 
    }
    //----------------------------------------------------------------------------------------------
    wTempSetBcFrom = Tempbc();
    if(uFuncSet == 14) //自清洁
    {
        wTempSetBc = (wTempSet + wTempSetBcFrom + wTempSetBcAdj); //实际停止加热温度
    }
    else //普通
    {
        wTempSetBc = (wTempSet + wTempSetBcFrom + wTempSetBcAdj) - 200; //实际停止加热温度
    }

    if(uNewVerison)
    {
        wHeatTime = YyXx(wtHeatTimeMax[uFuncSet], wtHeatTimeMin[uFuncSet], wtTempMaxbf[uFuncSet], wtTempMinbf[uFuncSet], wTempSet);
    }
    else
    {
        wHeatTime = YyXx(wtHeatTimeMax[uFuncSet], wtHeatTimeMin[uFuncSet], wtTempMax[uFuncSet], wtTempMin[uFuncSet], wTempSet);
    }
    U16N_HeatTime = ~wHeatTime;

    //----------------------------------------------------------------------------------------------
    if(uFastHeat >= 100) //快热
    {
        wFastTempSetBcFrom = TempSbc(wtFastSet, wtFastSbc, uFastHeat);
        wFastHeatBc = (uFastHeat + wFastTempSetBcFrom + wTempSetBcAdj) - 200;
        wFastHeatTime = YyXx(80, 30, 250, 100, uFastHeat);
        U16N_FastHeatTime = ~wFastHeatTime;
    }

    //----------------------------------------------------------------------------------------------
    if(uPowerUpCnt < n_20ms_5s) //上电计时 
    {
        uPowerUpCnt ++; 
        if(uPowerUpCnt < n_20ms_3s)
        {
            wTempOutHeart = wTempNt;
            wHwCnt = 0;
        }
    }
    if(uWork_F != n_WorkKeepTemp)
    {
        if(++wHwCnt >= n_20ms_10s)
        {
            wHwCnt = 0;
            if(wTempNt > wTempOutHeart)
            {
                wTempOutHeart ++;
            }
            else if(wTempNt < wTempOutHeart)
            {
                wTempOutHeart --;
            }
        }
    }

    //----------------------------------------------------------------------------------------------
    if(uOnOff_FF != uOnOff_F)
    {
        uOnOff_FF = uOnOff_F;
        if(uOnOff_F == 0) //关机动作,关照明灯
        {
            uDspLed_F = 0;
        }
    }

    //----------------------------------------------------------------------------------------------
    if(uDebug_F == 0)
    {
        wDebugCnt = 0;
        if(uWork_F == n_WorkKeepTemp) //恒温运行 
        {
            if(bKeepTempDriver_F == 0)
            {
                bKeepTempDriver_F = 1;
                uKeepTempDriver1Cnt = 0;
                wKeepTempDriver2Cnt = 0;

                uFunc10_F = 0;
                wFunc10HeatTime = 0;
                wFunc10KeepTime = 0;
                uFunc10HeatNum = 5;
                uFunc10HeatCnt = 0;

                uFunc14Heat_F = 0;
                wFunc14HeatCnt = 0;

                uFunc15Heat_F = 0;
                wFunc15HeatCnt = 0;
                
                wHwStopCnt = 0;
                uHwStart1Cnt = 0;
                wHwStart2Cnt = 0;
                uHw_F = 1;

                if(uFastHeat < 100)
                {
                    switch(uFuncSet)
                    {
                    case 1: //上下管
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 1;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 2: //热风
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 3: //上下+风
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 1;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 4: //上内
                        //bUpInHeat_F  = 1;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 5: //双上+风
                        //bUpInHeat_F  = 1;
                        //bUpOutHeat_F = 1;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 6: //双上
                        //bUpInHeat_F  = 1;
                        //bUpOutHeat_F = 1;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 7: //下+风
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 8: //下管
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 9: //上管
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 1;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 10: //热风ECO
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 0; //要延时15分钟再启动, 需要先关闭
                        uDspLed_F = 1;
                        break;
                    case 11: //解冻
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 12: //发酵
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 1;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 13: //保温
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 0;
                        uDspLed_F = 1;
                        break;
                    case 14: //自清洁
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 15: //空气炸
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 0;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 16://水解功能
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    case 17://干果功能
                        //bUpInHeat_F  = 0;
                        //bUpOutHeat_F = 0;
                        //bDownHeat_F  = 1;
                        //bBankHeat_F  = 1;
                        bFanCircle_F = 1;
                        bFanOut_F = 1;
                        uDspLed_F = 1;
                        break;
                    default:
                        bUpInHeat_F  = 0;
                        bUpOutHeat_F = 0;
                        bDownHeat_F  = 0;
                        bBankHeat_F  = 0;
                        bFanCircle_F = 0;
                        bFanOut_F = 0;
                        uDspLed_F = 0;
                        uFuncSet = 0; //其他 
                        break;
                    }
                }
                else
                {
                    //bUpInHeat_F  = 1;
                    //bUpOutHeat_F = 0;
                    //bDownHeat_F  = 0;
                    //bBankHeat_F  = 1;
                    bFanCircle_F = 1;
                    bFanOut_F = 1;
                    uDspLed_F = 1;
                }
            }
            else
            {
                if(++ uKeepTempDriver1Cnt >= n_20ms_1s) //20mms->1s
                {
                    uKeepTempDriver1Cnt = 0;
                    if(wKeepTempDriver2Cnt < 65000) //18hour
                    {
                        wKeepTempDriver2Cnt ++;
                    }
                }
                //----------------------------------------------------------------------------------
                if(uFastHeat < 100)
                {
                    if(uFuncSet == 10) //热风 ECO
                    {
                        if(wKeepTempDriver2Cnt < 900) //延时15分钟启动
                        {
                            bFanOut_F = 0; 
                        }
                        else
                        {
                            bFanOut_F = 1; 
                        }
                    }
                    if(uFuncSet == 14) //自清洁
                    {
                        if(wTempNt >= 340) 
                        {
                            bFanOut_F = 2; //使用高速风机 
                        }
                    }

                    //------------------------------------------------------------------------------
                    // 继电器控制 
                    //------------------------------------------------------------------------------
                    if(Hw() == 0)
                    {
                        bUpInHeat_F  = 0;
                        bUpOutHeat_F = 0;
                        bDownHeat_F  = 0;
                        bBankHeat_F  = 0;
                        uHWEnd = 1;
                    }
                    else
                    {
                        uHWEnd = 0;
                        switch(uFuncSet)
                        {
                        case 1: //上下管
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 1;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 0;
                            break;
                        case 2: //热风
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 1;
                            break;
                        case 3: //上下+风
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 1;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 0;
                            break;
                        case 4: //上内
                            bUpInHeat_F  = 1;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 0;
                            break;
                        case 5: //双上+风
                            bUpInHeat_F  = 1;
                            bUpOutHeat_F = 1;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 0;
                            break;
                        case 6: //双上
                            bUpInHeat_F  = 1;
                            bUpOutHeat_F = 1;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 0;
                            break;
                        case 7: //下+风
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 1;
                            break;
                        case 8: //下管
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 0;
                            break;
                        case 9: //上管
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 1;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 0;
                            break;
                        case 10: //热风ECO
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 1;
                            break;
                        case 11: //解冻
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 1;
                            break;
                        case 12: //发酵
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 0;
                            break;
                        case 13: //保温
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 0;
                            break;
                        case 14: //自清洁 
                            if(uFunc14Heat_F == 0) //热风+下管
                            {
                                bUpInHeat_F  = 0;
                                bUpOutHeat_F = 0;
                                bDownHeat_F  = 1;
                                bBankHeat_F  = 1;
                                if(wTempNt >= 450)
                                {
                                    uFunc14Heat_F = 1;
                                    wFunc14HeatCnt = 0;
                                }
                            }
                            else
                            {
                                if(uFunc14Heat_F == 1) //下管+上外管
                                {
                                    bUpInHeat_F  = 0;
                                    bUpOutHeat_F = 1;
                                    bDownHeat_F  = 1;
                                    bBankHeat_F  = 0;
                                    if(++wFunc14HeatCnt >= n_20ms_2min)
                                    {
                                        wFunc14HeatCnt = 0;
                                        uFunc14Heat_F = 2;
                                    }
                                }
                                else if(uFunc14Heat_F == 2) //热风+上内管
                                {
                                    bUpInHeat_F  = 1;
                                    bUpOutHeat_F = 0;
                                    bDownHeat_F  = 0;
                                    bBankHeat_F  = 1;
                                    if(++wFunc14HeatCnt >= n_20ms_3min)
                                    {
                                        wFunc14HeatCnt = 0;
                                        uFunc14Heat_F = 3;
                                    }
                                }
                                else if(uFunc14Heat_F == 3) //热风+下管
                                {
                                    bUpInHeat_F  = 0;
                                    bUpOutHeat_F = 0;
                                    bDownHeat_F  = 1;
                                    bBankHeat_F  = 1;
                                    if(++wFunc14HeatCnt >= n_20ms_5min)
                                    {
                                        wFunc14HeatCnt = 0;
                                        uFunc14Heat_F = 1;
                                    }
                                }
                                else
                                {
                                    wFunc14HeatCnt = 0;
                                    uFunc14Heat_F = 1;
                                }
                            }
                            break;
                        case 15: //空气炸
                            if(uFunc15Heat_F == 0) //热风+上内管 8min
                            {
                                bUpInHeat_F  = 1;
                                bUpOutHeat_F = 0;
                                bDownHeat_F  = 0;
                                bBankHeat_F  = 1;
                                if(++wFunc15HeatCnt >= n_20ms_8min)
                                {
                                    wFunc15HeatCnt = 0;
                                    uFunc15Heat_F = 1;
                                }
                            }
                            else if(uFunc15Heat_F == 1)
                            {
                                bUpInHeat_F  = 0;
                                bUpOutHeat_F = 1;
                                bDownHeat_F  = 0;
                                bBankHeat_F  = 1;
                                if(++wFunc15HeatCnt >= n_20ms_5min)
                                {
                                    wFunc15HeatCnt = 0;
                                    uFunc15Heat_F = 2;
                                }
                            }
                            else if(uFunc15Heat_F == 2)
                            {
                                bUpInHeat_F  = 0;
                                bUpOutHeat_F = 0;
                                bDownHeat_F  = 1;
                                bBankHeat_F  = 1;
                                if(++wFunc15HeatCnt >= n_20ms_3min)
                                {
                                    wFunc15HeatCnt = 0;
                                    uFunc15Heat_F = 3;
                                }
                            }
                            else
                            {
                                bUpInHeat_F  = 1;
                                bUpOutHeat_F = 0;
                                bDownHeat_F  = 1;
                                bBankHeat_F  = 0;
                                if(++wFunc15HeatCnt >= n_20ms_5min)
                                {
                                    wFunc15HeatCnt = 0;
                                    uFunc15Heat_F = 0;
                                }
                            }
                            break;
                        case 16:
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 1;
                            bBankHeat_F  = 0;
                            break;
                        case 17:
                            bUpInHeat_F  = 1;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 0;
                            break;
                        default:
                            bUpInHeat_F  = 0;
                            bUpOutHeat_F = 0;
                            bDownHeat_F  = 0;
                            bBankHeat_F  = 0;
                            uFuncSet = 0; //其他 
                            break;
                        }
                    }
                }
                else //快热 
                {
                    if(Hw() == 0)
                    {
                        bUpInHeat_F  = 0;
                        bUpOutHeat_F = 0;
                        bDownHeat_F  = 0;
                        bBankHeat_F  = 0;
                        uHWEnd = 1;
                        //if(wTempNt >= wFastHeatBc) //第一次恒温后不报故障,继续加热
                        {
                            uFastHeatFirst_F = n_ErrorFastHeat;
                        }
                    }
                    else //旧(上内管+热风), 新(上内管+上外管) //Mark20241107
                    {
//                        bUpInHeat_F  = 1;
//                        bUpOutHeat_F = 1;
//                        bDownHeat_F  = 0;
//                        bBankHeat_F  = 0;
//                        uHWEnd = 0;
                        //速热改回 上内管+热风 20241227
                        bUpInHeat_F  = 1;
                        bUpOutHeat_F = 0;
                        bDownHeat_F  = 0;
                        bBankHeat_F  = 1;
                        uHWEnd = 0;                        
                    }
//                    if(wTempNt >= wFastHeatBc) //第一次恒温后不报故障,继续加热
//                    {
//                        uFastHeatFirst_F = n_ErrorFastHeat;
//                    }
                }
            }
        }
        else
        {
            bKeepTempDriver_F = 0;
            bUpInHeat_F  = 0;
            bUpOutHeat_F = 0;
            bDownHeat_F  = 0;
            bBankHeat_F  = 0;
            bFanCircle_F = 0;
            if(uWork_F != n_WorkLastClean) //非后清扫状态
            {
                bFanOut_F = 0;
                //uDspLed_F = 0;
            }
        }
    }
    else
    {
        bKeepTempDriver_F = 0;
        if(uDebug_F == 7)
        {
            if(wDebugCnt < n_20ms_15s)
            {
                wDebugCnt ++;
            }
            if(uDebugIndex == 1)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 1;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 0;
                if(wDebugCnt >= n_20ms_2s)
                {
                    bUpOutHeat_F = 0;
                }
            }
            else if(uDebugIndex == 2)
            {
                bUpInHeat_F  = 1;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 0;
                if(wDebugCnt >= n_20ms_2s)
                {
                    bUpInHeat_F  = 0;
                }
            }
            else if(uDebugIndex == 3)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 1;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 0;
                if(wDebugCnt >= n_20ms_2s)
                {
                    bBankHeat_F  = 0;
                }
            }
            else if(uDebugIndex == 4)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 1;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 0;
                if(wDebugCnt >= n_20ms_2s)
                {
                    bDownHeat_F  = 0;
                }
            }
            else if(uDebugIndex == 5)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 1;
                bFanOut_F = 0;
                uDspLed_F = 0;
                if(wDebugCnt >= n_20ms_2s)
                {
                    bFanCircle_F = 0;
                }
            }
            else if(uDebugIndex == 6)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 1;
                uDspLed_F = 0;
                if(wDebugCnt >= n_20ms_2s)
                {
                    bFanOut_F = 0;
                }
            }
            else if(uDebugIndex == 7)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 1;
                if(wDebugCnt >= n_20ms_2s)
                {
                    uDspLed_F = 0;
                }
            }
            else
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 0;
            }
        }
        else if(uDebug_F == 9)
        {
            wDebugCnt ++;
            if(wDebugCnt == n_20ms_100ms)
            {
                bUpInHeat_F  = 1;
                bUpOutHeat_F = 1;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 1;
                bFanOut_F = 1;
                uDspLed_F = 1;
            }
            else if(wDebugCnt == n_20ms_3min)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 1;
                bBankHeat_F  = 1;
                bFanCircle_F = 1;
                bFanOut_F = 1;
                uDspLed_F = 1;
            }
            else if(wDebugCnt == n_20ms_6min)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 1;
                bFanOut_F = 1;
                uDspLed_F = 1;
            }
            else if(wDebugCnt >= n_20ms_7min)
            {
                bUpInHeat_F  = 0;
                bUpOutHeat_F = 0;
                bDownHeat_F  = 0;
                bBankHeat_F  = 0;
                bFanCircle_F = 0;
                bFanOut_F = 0;
                uDspLed_F = 0;
                uDebug_F = 0; //退出测试 
            }
        }
        else
        {
            bUpInHeat_F  = 0;
            bUpOutHeat_F = 0;
            bDownHeat_F  = 0;
            bBankHeat_F  = 0;
            bFanCircle_F = 0;
            bFanOut_F = 0;
            uDspLed_F = 0;
            wDebugCnt = 0;
        }
    }
}

//==================================================================================================
// Function    : 恒温控制
// Input       :
// Output      :
// Description :
//==================================================================================================
U8 Hw(void)
{
    U8  uFlag = 0;
    U16 wTmp = 0;
    U16 wSetAdd = 0;
        wSetDec = 0;

    if(uFastHeat < 100)
    {
        if((uFuncSet == 10)&&(uFunc10_F < 4)) //热风eco
        {
            if(uFunc10_F == 0)
            {
                wFunc10HeatTime = n_1s_1min;
                wFunc10KeepTime = n_20ms_1min5;
                uFunc10HeatNum = 5;
            }
            else if(uFunc10_F == 1)
            {
                wFunc10HeatTime = n_1s_1min;
                wFunc10KeepTime = n_20ms_2min5;//20240425_1
                uFunc10HeatNum = 13;//20240425_1
            }
            else if(uFunc10_F == 2)
            {
                wFunc10HeatTime = n_1s_1min;
                wFunc10KeepTime = n_20ms_3min;
                uFunc10HeatNum = 8;//20240422_1
            }
            else if(uFunc10_F == 3)
            {
                wFunc10HeatTime = n_1s_1min;
                wFunc10KeepTime = n_20ms_1min;
                uFunc10HeatNum = 10;
            }

            if(uHw_F)
            {
                if(++uHwStart1Cnt >= n_20ms_1s)
                {
                    uHwStart1Cnt = 0;
                    if(wHwStart2Cnt < 2500) //2500秒 
                    {
                        wHwStart2Cnt ++;
                    }
                    if(wHwStart2Cnt >= wFunc10HeatTime)
                    {
                        uHw_F = 0;
                        wHwStart2Cnt = 0;
                    }
                }
                wHwStopCnt = 0;
            }
            else
            {
                uHwStart1Cnt = 0;
                wHwStart2Cnt = 0;
                if(++wHwStopCnt >= wFunc10KeepTime)
                {
                    if(wTempNt <= wTempSetBc)
                    {
                        wHwStopCnt = 0;
                        uHw_F = 1;
                        if(++uFunc10HeatCnt >= uFunc10HeatNum)
                        {
                            uFunc10HeatCnt = 0;
                            if(++uFunc10_F >= 4)
                            {
                                uFunc10_F = 4;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            if(uHw_F)
            {
                switch(uFuncSet)
                {
                case 1: //上下管, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 250)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec >  4)
                            {
                                wSetDec =  4;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 10)
                            {
                                wSetDec = 10;
                            }
                        }
                        else
                        {
                            if(wSetDec > 12)
                            {
                                wSetDec = 12;
                            }
                        }
                    }
                    break;
                case 2: //热风, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 250)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  3)
                            {
                                wSetDec =  3;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec >  7)
                            {
                                wSetDec =  7;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 10)
                            {
                                wSetDec = 10;
                            }
                        }
                        else
                        {
                            if(wSetDec > 12)
                            {
                                wSetDec = 12;
                            }
                        }
                    }
                    break;
                case 3: //上下+风, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 250)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  3)
                            {
                                wSetDec =  3;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec >  7)
                            {
                                wSetDec =  7;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 10)
                            {
                                wSetDec = 10;
                            }
                        }
                        else
                        {
                            if(wSetDec > 12)
                            {
                                wSetDec = 12;
                            }
                        }
                    }
                    break;
                case 4: //上内, 这个模式第一次加热温度上升有点慢
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetAdd = wTempSet - wTempOutHeart;
                        wSetAdd <<= 1;
                        if(wTempSet >= 250)
                        {
                            if(wSetAdd > 15)
                            {
                                wSetAdd = 15;
                            }
                        }
                        else if(wTempSet >= 225)
                        {
                            if(wSetAdd > 30)
                            {
                                wSetAdd = 30;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetAdd > 40)
                            {
                                wSetAdd = 40;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetAdd > 50)
                            {
                                wSetAdd = 50;
                            }
                        }
                        else
                        {
                            if(wSetAdd > 50)
                            {
                                wSetAdd = 50;
                            }
                        }
                    }
                    break;
                case 5: //双上+风, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 220)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  8)
                            {
                                wSetDec =  8;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec >  8)
                            {
                                wSetDec =  8;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 10)
                            {
                                wSetDec = 10;
                            }
                        }
                        else
                        {
                            if(wSetDec > 12)
                            {
                                wSetDec = 12;
                            }
                        }
                    }
                    break;
                case 6: //双上, 这个模式第一次加热温度上升有点慢
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetAdd = wTempSet - wTempOutHeart;
                        wSetAdd <<= 1;
                        if(wTempSet >= 250)
                        {
                            if(wSetAdd > 15)
                            {
                                wSetAdd = 15;
                            }
                        }
                        else if(wTempSet >= 225)
                        {
                            if(wSetAdd > 30)
                            {
                                wSetAdd = 30;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetAdd > 50)
                            {
                                wSetAdd = 50;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetAdd > 60)
                            {
                                wSetAdd = 60;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetAdd > 60)
                            {
                                wSetAdd = 60;
                            }
                        }
                        else
                        {
                            if(wSetAdd > 60)
                            {
                                wSetAdd = 60;
                            }
                        }
                    }
                    break;
                case 7: //下+风, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 250)
                        {
                            if(wSetDec >  4)
                            {
                                wSetDec =  4;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  8)
                            {
                                wSetDec =  8;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec > 10)
                            {
                                wSetDec = 10;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 12)
                            {
                                wSetDec = 12;
                            }
                        }
                        else
                        {
                            if(wSetDec > 14)
                            {
                                wSetDec = 14;
                            }
                        }
                    }
                    break;
                case 8: //下管, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 250)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  2)
                            {
                                wSetDec =  2;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec >  5)
                            {
                                wSetDec =  5;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 14)
                            {
                                wSetDec = 14;
                            }
                        }
                        else
                        {
                            if(wSetDec > 16)
                            {
                                wSetDec = 16;
                            }
                        }
                    }
                    break;
                case 9: //上管, 这个模式第一次加热温度上升有点慢
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetAdd = wTempSet - wTempOutHeart;
                        wSetAdd <<= 1;
                        if(wTempSet >= 250)
                        {
                            if(wSetAdd >  1)
                            {
                                wSetAdd =  1;
                            }
                        }
                        else if(wTempSet >= 220)
                        {
                            if(wSetAdd >  5)
                            {
                                wSetAdd =  5;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetAdd > 20)
                            {
                                wSetAdd = 20;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetAdd > 38)
                            {
                                wSetAdd = 38;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetAdd > 38)
                            {
                                wSetAdd = 38;
                            }
                        }
                        else
                        {
                            if(wSetAdd > 38)
                            {
                                wSetAdd = 38;
                            }
                        }
                    }
                    break;
                case 10: //热风ECO
                    
                    break;
                case 11: //解冻, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 2;
                        if(wTempSet >=  75)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  65)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  55)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  45)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                    }
                    break;
                case 12: //发酵, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 2;
                        if(wTempSet >=  75)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  65)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  55)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  45)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                    }
                    break;
                case 13: //保温, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 2;
                        if(wTempSet >=  75)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  65)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  55)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  45)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                    }
                    break;
                case 14: //自清洁 
                    
                    break;
                case 15: //空气炸, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 3;
                        if(wTempSet >= 250)
                        {
                            if(wSetDec >  1)
                            {
                                wSetDec =  1;
                            }
                        }
                        else if(wTempSet >= 200)
                        {
                            if(wSetDec >  3)
                            {
                                wSetDec =  3;
                            }
                        }
                        else if(wTempSet >= 150)
                        {
                            if(wSetDec >  7)
                            {
                                wSetDec =  7;
                            }
                        }
                        else if(wTempSet >= 100)
                        {
                            if(wSetDec > 10)
                            {
                                wSetDec = 10;
                            }
                        }
                        else
                        {
                            if(wSetDec > 12)
                            {
                                wSetDec = 12;
                            }
                        }
                    }
                    break;
                    case 16: //水解, 这个模式第一次加热温度上升有点快
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 2;
                        if(wTempSet >=  150)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  140)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  120)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  100)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                    }
                    break;
                    case 17: //干果
                    if(wTempOutHeart < wTempSet)
                    {
                        wSetDec = wTempSet - wTempOutHeart;
                        wSetDec /= 2;
                        if(wTempSet >=  85)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  80)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  70)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else if(wTempSet >=  60)
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                        else
                        {
                            if(wSetDec > 18)
                            {
                                wSetDec = 18;
                            }
                        }
                    }
                    break;
                default:
                    break;
                }

                //-----------------------------------------------------------------------------------------
                if(++uHwStart1Cnt >= n_20ms_1s)
                {
                    uHwStart1Cnt = 0;
                    if(wHwStart2Cnt < 2500) //2500秒 
                    {
                        wHwStart2Cnt ++;
                    }
                    if(wHwStart2Cnt >= wHeatTime) //30-240秒 
                    {
                        if((wTempNt + wSetDec) >= (wTempSetBc + wSetAdd)) 
                        {
                            uHw_F = 0;
                            wHwStart2Cnt = 0;
                        }
                    }
                }
                if((wTempNt + wSetDec) >= (wTempSetBc + wSetAdd + 20)) //退出加热条件 
                {
                    uHw_F = 0;
                    uHwStart1Cnt = 0;
                    wHwStart2Cnt = 0;
                }
                if(uHw_F == 0) //加热结束,预置为设置温度
                {
                    wTempOutHeart = wTempSet; 
                    wSetDecBuf = wSetDec;
                }
                wHwStopCnt = 0; 
            }
            else //----------------------------------------------------------------------------------------
            {
                if((uFuncSet == 8)||(uFuncSet == 12)||(uFuncSet == 13)) //8.下管 12.发酵 13.保温
                {
                    uHwStart1Cnt = 0;
                    wHwStart2Cnt = 0;
                    if(wSetDecBuf > 1)
                    {
                        if(wTempSet < 90)
                        {
                            wTmp = n_20ms_8min; //时间加长：因为中心点温度上来了，探头温度没有上来
                        }
                        else
                        {
                            wTmp = n_20ms_5min;
                        }
                        if(++wHwStopCnt >= wTmp)
                        {
                            if(wTempNt <= wTempSetBc) //温度1分钟内不再上升,且小于补偿值
                            {
                                wHwStopCnt = 0;
                                uHw_F = 1;
                            }
                        }
                    }
                    else
                    {
                        if(++wHwStopCnt >= n_20ms_2min)
                        {
                            if(wTempNt <= wTempSetBc) //温度2分钟内不再上升,且小于补偿值
                            {
                                wHwStopCnt = 0;
                                uHw_F = 1;
                            }
                        }
                    }
                    //这三个模式是下加热，在低温时温度传导比较慢,温度需要慢慢加上去,所以一定会等两分钟
                    if((wTempNt + 50) <= wTempSetBc)
                    {
                        wHwStopCnt = 0;
                        uHw_F = 1;
                    }
                }
                else
                {
                    uHwStart1Cnt = 0;
                    wHwStart2Cnt = 0;
                    if((wTempSet >= 150)&&((uFuncSet == 2)||(uFuncSet == 5)||(uFuncSet == 10))) //2.热风 5.双上+风 10.热风ECO
                    {
                        wTmp = n_20ms_1min;
                    }
                    else
                    {
                        wTmp = n_20ms_2min;
                    }
                    if(++wHwStopCnt >= wTmp)
                    {
                        if(wTempNt <= wTempSetBc)
                        {
                            wHwStopCnt = 0;
                            uHw_F = 1;
                        }
                    }
                    if((wTempNt + 20) <= wTempSetBc)
                    {
                        wHwStopCnt = 0;
                        uHw_F = 1;
                    }
                }
            }
        }
    }
    //----------------------------------------------------------------------------------------------
    else //快热功能处理 
    {
        if(uHw_F)
        {
            if(++uHwStart1Cnt >= n_20ms_1s)
            {
                uHwStart1Cnt = 0;
                if(wHwStart2Cnt < 2500) //2500秒
                {
                    wHwStart2Cnt ++;
                }
                if(wHwStart2Cnt >= wFastHeatTime) //30-80秒
                {
                    if(wTempNt >= wFastHeatBc)
                    {
                        uHw_F = 0;
                        wHwStart2Cnt = 0;
                    }
                }
            }
            if(wTempNt >= (wFastHeatBc + 20))
            {
                uHw_F = 0;
                uHwStart1Cnt = 0;
                wHwStart2Cnt = 0;
            }
            if(uHw_F == 0) //加热结束,预置为设置温度
            {
                wTempOutHeart = wTempSet;
            }
            wHwStopCnt = 0;
        }
        else
        {
            uHwStart1Cnt = 0;
            wHwStart2Cnt = 0;
            if(++wHwStopCnt >= n_20ms_2min)
            {
                if(wTempNt <= wFastHeatBc)
                {
                    wHwStopCnt = 0;
                    uHw_F = 1;
                }
            }
            if((wTempNt + 20) <= wFastHeatBc)
            {
                wHwStopCnt = 0;
                uHw_F = 1;
            }
        }
    }

    //手动调节补偿温度,使用LED指示
    if(uTempSetBcAdj_F)
    {
        if(uHw_F)
        {
            uDspLed_F = 1;
        }
        else
        {
            uDspLed_F = 0;
        }
    }

    uFlag = uHw_F;
    return uFlag;
}

//==================================================================================================
// Function    : 查表补偿温度 
// Input       :
// Output      :
// Description :
//==================================================================================================
U16 TempSbc(const U16 *wtSet, const U16 *wtSbc, U16 wSet)
{
    U8 uI;
    U16 wTmp;
    U32 ulTmp;

    if(wSet <= wtSet[0])
    {
        wTmp = wtSbc[0];
    }
    else if(wSet >= wtSet[5])
    {
        wTmp = wtSbc[5];
    }
    else
    {
        for(uI = 1; uI < 6; uI ++)
        {
            if(wSet < wtSet[uI])
            {
                break;
            }
        }
        if(wtSbc[uI] >= wtSbc[uI - 1])
        {
            ulTmp = (U32)(wSet - wtSet[uI - 1]);
            ulTmp *= (U32)(wtSbc[uI] - wtSbc[uI - 1]);
            ulTmp /= (U32)(wtSet[uI] - wtSet[uI - 1]);
            ulTmp += (U32)wtSbc[uI - 1];
        }
        else
        {
            ulTmp = (U32)(wSet - wtSet[uI - 1]);
            ulTmp *= (U32)(wtSbc[uI-1] - wtSbc[uI]); //100 150, 130 110
            ulTmp /= (U32)(wtSet[uI] - wtSet[uI - 1]); 
            ulTmp = ((U32)wtSbc[uI-1]) - ulTmp;
        }
        wTmp = (U16)ulTmp;
    }
    return(wTmp);
}

//==================================================================================================
// Function    : 计算补偿温度
// Input       :
// Output      :
// Description :
//==================================================================================================
U16 Tempbc(void)
{
    U16 wTmp = 100;
    switch(uFuncSet)
    {
    case 1: //上下管
        wTmp = TempSbc(wtTempSet1,  wtTempSbc1,  wTempSet);
        break;
    case 2: //热风
        wTmp = TempSbc(wtTempSet2,  wtTempSbc2,  wTempSet);
        break;
    case 3: //上下+风
        wTmp = TempSbc(wtTempSet3,  wtTempSbc3,  wTempSet);
        break;
    case 4: //上内
        wTmp = TempSbc(wtTempSet4,  wtTempSbc4,  wTempSet);
        break;
    case 5: //双上+风
        wTmp = TempSbc(wtTempSet5,  wtTempSbc5,  wTempSet);
        break;
    case 6: //双上
        wTmp = TempSbc(wtTempSet6,  wtTempSbc6,  wTempSet);
        break;
    case 7: //下+风
        wTmp = TempSbc(wtTempSet7,  wtTempSbc7,  wTempSet);
        break;
    case 8: //下管
        wTmp = TempSbc(wtTempSet8,  wtTempSbc8,  wTempSet);
        break;
    case 9: //上管
        wTmp = TempSbc(wtTempSet9,  wtTempSbc9,  wTempSet);
        break;
    case 10: //热风ECO
        wTmp = TempSbc(wtTempSet10, wtTempSbc10, wTempSet);
        break;
    case 11: //解冻
        wTmp = TempSbc(wtTempSet11, wtTempSbc11, wTempSet);
        break;
    case 12: //发酵
        wTmp = TempSbc(wtTempSet12, wtTempSbc12, wTempSet);
        break;
    case 13: //保温
        wTmp = TempSbc(wtTempSet13, wtTempSbc13, wTempSet);
        break;
    case 14: //自清洁
        wTmp = TempSbc(wtTempSet14, wtTempSbc14, wTempSet);
        break;
    case 15: //空气炸
        wTmp = TempSbc(wtTempSet15, wtTempSbc15, wTempSet);
        break;
    //新增水解功能
    case 16:
        wTmp = TempSbc(wtTempSet16, wtTempSbc16, wTempSet);
        break;
    case 17://新增干果功能 Mark 20250603
        wTmp = TempSbc(wtTempSet17, wtTempSbc17, wTempSet);
        break;
    default:
        wTmp = TempSbc(wtTempSet0,  wtTempSbc0,  wTempSet);
        break;
    }
    return wTmp;
}

//==================================================================================================
// Function    : 计算设定温度对应的加热时间 
// Input       :
// Output      :
// Description :
//==================================================================================================
U16 YyXx(U16 wYmax,U16 wYmin,U16 wXmax,U16 wXmin,U16 wX)
{
    S32 slTmp;
    U16 wTmp;
    if(wXmax > wXmin)
    {
        if(wYmax >= wYmin)
        {
            slTmp = (S32)wX;
            slTmp -= (S32)wXmin;
            slTmp *= (S32)(wYmax - wYmin);
            slTmp /= (S32)(wXmax - wXmin);
            slTmp += (S32)wYmin;
            if(slTmp > 60000)
            {
                slTmp = 60000;
            }
            if(slTmp < 0)
            {
                slTmp = 0;
            }
            wTmp = (U16)slTmp;
        }
        else
        {
            slTmp = (S32)wX;
            slTmp -= (S32)wXmin;
            slTmp *= (S32)(wYmin - wYmax); //0-100, 20, 20,10
            slTmp /= (S32)(wXmax - wXmin);
            slTmp = ((S32)wYmin) - slTmp;
            if(slTmp > 60000)
            {
                slTmp = 60000;
            }
            if(slTmp < 0)
            {
                slTmp = 0;
            }
            wTmp = (U16)slTmp;
        }
    }
    else
    {
        wTmp = wYmin;
    }
    return wTmp;
}

//==================================================================================================
//                                  THE END
//==================================================================================================

